package cn.tedu.csmall.stock.webapi.kafka;

import cn.tedu.csmall.commons.pojo.stock.entity.Stock;
import com.google.gson.Gson;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;

//@Component
public class Consumer {
    @KafkaListener(topics = "myStock")
    public void received(ConsumerRecord<String,String> record){
        //获取信息内容
        String json = record.value();
        //转换格式
        Gson gson= new Gson();
        Stock stock = gson.fromJson(json, Stock.class);
        System.out.println("接受对象为:"+stock);
    }
}
